home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_pcdp / adas / global.pas < prev    next >
Pascal/Delphi Source File  |  1996-01-30  |  5KB  |  132 lines

  1. unit global;
  2.  
  3. {  Global definitions }
  4.  
  5. interface
  6.  
  7. const
  8.   nkw     = 31;    { number of reserved keywords }
  9.   alng    = 10;    { length of an "alfa" string }
  10.   llng    = 100;   { length of an input line }
  11.   kmax    = 12;    { maximum digits in a number }
  12.   tmax    = 50;    { maximum entries in symbol table }
  13.   bmax    = 10;    { maximum number of blocks }
  14.   amax    = 4;     { maximum number of arrays }
  15.   cmax    = 200;   { maximum number of code instructions }
  16.   lmax    = 4;     { maximum levels of nesting }
  17.   smax    = 150;   { maximum total length of strings }
  18.   stmax   = 1400;  { maximum total length of stack }
  19.   stkincr = 200;   { stack increment for each process }
  20.   pmax    = 3;     { maximum number of processes }
  21.   emax    = 5;     { maximum number of entries }
  22.   initmax = 5;     { maximum variables to initialize }
  23.  
  24. type
  25.   symbol=
  26.     (intcon, charcon, strng,
  27.      notsy, plus, minus, times, idiv, imod, andsy, orsy,
  28.      eql, neq, gtr, geq, lss, leq,
  29.      lparent, rparent, comma, semicolon, period, colon, becomes,
  30.      constsy, typesy, proceduresy, arraysy, ident,
  31.      beginsy, ifsy, whilesy, forsy,
  32.      endsy, elsesy, ofsy, dosy, tosy, thensy,
  33.      issy, insy, loopsy, tasksy, bodysy, terminate,
  34.      elsif, exitsy, when, outsy, acceptsy, selectsy, arrow,
  35.      nullsy, pragmasy);
  36.  
  37.   object   = (konstant, variable, type1, prozedure, funktion, task);
  38.   parmmode = (noparm,   inparm,   outparm);
  39.  
  40.   types    = (notyp, ints,  bools, chars, arrays);
  41.   er       = (erid,  ertyp, erkey, erpun, erpar,
  42.               ernf,  erdup, erch,  ersh,  erln);
  43.  
  44.   ptype    = 0..pmax;
  45.   alfa     = packed array[1..alng] of char;
  46.   symset   = set of symbol;
  47.   typset   = set of types;
  48.  
  49.   item=             { description of an expression in the compiler }
  50.     record          { fields as in tab }
  51.       typ: types;
  52.       ref: integer;
  53.     end;
  54.  
  55.   order=            { byte code: instruction + two parameters }
  56.     packed record
  57.       f: byte;
  58.       x: byte;
  59.       y: integer;
  60.     end;
  61.  
  62. var
  63.   inputfile: string[20];     { input file name }
  64.   entries:   integer;        { number of entries }
  65.   curtask:   integer;        { current task }
  66.   elabs:     integer;        { number of tasks to elaborate }
  67.   inits:     integer;        { number of variables to initialize }
  68.  
  69.   display: array[0..lmax] of integer;
  70.                              { reflects static links for addressing }
  71.  
  72.   tab: array[0..tmax] of     { symbol table }
  73.          packed record
  74.            name:   alfa;     { symbol name }
  75.            link:   integer;  { link to previous symbol in block }
  76.            obj:    object;   { variable, procedure, etc. }
  77.            typ:    types;    { integer, char, etc. }
  78.            ref:    integer;  { reference to block or array table }
  79.            normal: boolean;  { false = indirect reference "out" parm }
  80.            lev:    0..lmax;  { static level: 0 = predefined, 1 = main }
  81.            adr:    integer;  { constant = value, type = size,
  82.                               variable = offset on stack }
  83.          end;
  84.  
  85.   atab: array[1..amax] of    { array table }
  86.           packed record
  87.             inxtyp: types;   { index type }
  88.             eltyp:  types;   { element type }
  89.             low:    integer; { lower index }
  90.             high:   integer; { higher index }
  91.             elsize: integer; { size of one element }
  92.             size:   integer; { total size of array }
  93.           end;
  94.  
  95.   btab: array[1..bmax] of     { block table }
  96.           packed record
  97.             last:    integer; { last identifier }
  98.             lastpar: integer; { last parameter }
  99.             psize:   integer; { size of activ. record + parms }
  100.             vsize:   integer; { psize + local variables }
  101.           end;
  102.  
  103.   inittab: array[1..initmax] of { initialization table }
  104.           packed record
  105.             addr:  integer;     { symbol table address }
  106.             value: integer;     { initial value }
  107.           end;
  108.  
  109.   elabtab: array[1..pmax] of integer; { elaboration table }
  110.  
  111.   stab: packed array[0..smax] of char; { string table }
  112.  
  113.   code: array[0..cmax] of order;  { code table }
  114.  
  115.   entry: array[0..emax] of     { entry table }
  116.           record
  117.             taskid:  integer;  { task containing the entry }
  118.             name:    alfa;     { entry name }
  119.             open:    integer;  { pc of accept statement }
  120.             waiting: ptype;    { first waiting process or
  121.                                  process in rendezvous }
  122.             p1mode:  parmmode; { first parameter mode }
  123.             p2mode:  parmmode; { second parameter mode }
  124.             p1loc:   integer;  { first parameter location }
  125.             p2loc:   integer   { second parameter location }
  126.           end;
  127.  
  128. const
  129.   stantyps: typset = [notyp, ints, bools, chars];
  130.  
  131. implementation
  132. end.